//
//  FavoriteSelectButton.m
//  SecondPage
//
//  Created by xiong qi on 13-4-19.
//  Copyright (c) 2013年 winston. All rights reserved.
//

#import "FavoriteSelectButton.h"
#import "FavoriteModuleView.h"

@implementation FavoriteSelectButton
@synthesize datasource;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        title_label = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, frame.size.width-20, 20)];
        title_label.font = [UIFont boldSystemFontOfSize:16];
        [title_label setBackgroundColor:[UIColor clearColor]];
        [self addSubview:title_label];
        [title_label release];
        
        description_label = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, frame.size.width-20, 30)];
        description_label.font = [UIFont boldSystemFontOfSize:12];
        description_label.numberOfLines = 2;
        [description_label setBackgroundColor:[UIColor clearColor]];
        [self addSubview:description_label];
        [description_label release];
    }
    return self;
}

-(void)RefreshByData:(NSDictionary *)dic
{
    if (dic) {
        title_label.text = [dic objectForKey:Favorite_Title];
        NSString * des = [[dic objectForKey:Favorite_Content] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
      
        if ([des isEqualToString:@""]) {
            title_label.frame = CGRectMake(10, (self.frame.size.height-20)/2, self.frame.size.width-20, 20);
            title_label.textAlignment = NSTextAlignmentCenter;
        }
        description_label.text =[dic objectForKey:Favorite_Content];
        self.datasource = dic;
    }
    
}

-(void)setNormal
{
    [super setNormal];
    title_label.textColor = [UIColor colorWithRed:0.4 green:0.4 blue:0.4 alpha:1.0];
    description_label.textColor = [UIColor colorWithRed:0.4 green:0.4 blue:0.4 alpha:1.0];
    
}

-(void)setHighLight
{
    [super setHighLight];
    title_label.textColor = [UIColor whiteColor];
    description_label.textColor = [UIColor whiteColor];
}

-(void)dealloc
{
    self.datasource = nil;
    [super dealloc];
}

@end
